<?php
namespace App\Models;


/**
 * Model Course
 *
 * @property int $id
 * @property int $school_id
 * @property int $campus_id
 * @property int $subject_id
 * @property int $class_id
 * @property int $teacher_id
 * @property int $classroom_id
 * @property int $course_type
 * @property int $start_time
 * @property int $end_time
 * @property int $len
 * @property string $note
 * @property string $created_at
 * @property string $updated_at
 * @property string $deleted_at
 *
 * @method static \Illuminate\Database\Query\Builder | \App\Models\Course where($column, $operator = null, $value = null, $boolean = 'and')
 * @method static \Illuminate\Database\Query\Builder | \App\Models\Course whereIn($column, $values, $boolean = 'and', $not = false)
 * @method static \Illuminate\Database\Query\Builder | \App\Models\Course leftJoin($table, $first, $operator = null, $second = null)
 * @method static \Illuminate\Database\Query\Builder | \App\Models\Course rightJoin($table, $first, $operator = null, $second = null)
 * @method static \Illuminate\Database\Query\Builder | \App\Models\Course get($columns = ['*'])
 * @method static \Illuminate\Database\Query\Builder | \App\Models\Course paginate($perPage = 15, $columns = ['*'], $pageName = 'page', $page = null)
 * @method static \Illuminate\Database\Query\Builder | \App\Models\Course find($id, $columns = ['*'])
 * @method static \Illuminate\Database\Query\Builder | \App\Models\Course first($columns = ['*'])
 * @method static \Illuminate\Database\Query\Builder | \App\Models\Course select($columns = ['*'])
 * @method static \Illuminate\Database\Query\Builder | \App\Models\Course orderBy($column, $direction = 'asc')
 * @package App\Model
 */
class Course extends BaseModel
{
    protected $table = 'course';

    public function subject()
    {
        return $this->belongsTo(Subject::class);
    }

    public function attendances(){
        return $this->hasMany(Attendance::class);
    }

    public function getSubjectNameAttribute()
    {
        return $this->subject ? $this->subject['subject_name'] : '';
    }

}
